﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Sai.Core.Introspection;

namespace Sai.Core
{
	/// <summary>
	/// Represents a change to a type's inheritance
	/// </summary>
	public class TypeInheritanceChange
	{
		public TypeInheritanceChange()
		{
		}

		public TypeInheritanceChange(TypeName from, TypeName to)
		{
			this.From = from == null ? string.Empty : from.FullName.ToString();
			this.To = to == null ? string.Empty : to.FullName.ToString();
		}

		[XmlAttribute("From")]
		public string From { get; set; }

		[XmlAttribute("To")]
		public string To { get; set; }

		public override string ToString()
		{
			if (string.IsNullOrEmpty(this.To))
			{
				return string.Format("No longer inherits from {0}", this.From);
			}
			
			return string.Format("Base type changed from {0} to {1}", this.From, this.To);
		}
	}
}